package hk.zdl.jddnspod;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.URL;

public class Tool {

	public static InetAddress getPublicAddress() throws IOException{
		InputStream in = new URL("http://city.ip138.com/ip2city.asp").openStream();
		BufferedReader reader = new BufferedReader(new InputStreamReader(in));
		StringBuilder sb = new StringBuilder();
		while(reader.ready()){
			sb.append(reader.readLine());
		}
		return InetAddress.getByName(sb.substring(sb.indexOf("[")+1, sb.indexOf("]")));
	}
}
